VERSION 5.00
Object = "{0ECD9B60-23AA-11D0-B351-00A0C9055D8E}#6.0#0"; "mshflxgd.ocx"
Object = "{0D452EE1-E08F-101A-852E-02608C4D0BB4}#2.0#0"; "FM20.DLL"
Begin VB.Form FPrecios 
   Caption         =   "Servicio - Precios"
   ClientHeight    =   7485
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   11790
   Icon            =   "FPrecios.frx":0000
   LinkTopic       =   "Form1"
   MinButton       =   0   'False
   ScaleHeight     =   7485
   ScaleWidth      =   11790
   StartUpPosition =   1  'CenterOwner
   Begin VB.Frame Frame2 
      Height          =   1095
      Left            =   120
      TabIndex        =   1
      Top             =   1080
      Width           =   11535
      Begin VB.TextBox txtmonto 
         Alignment       =   1  'Right Justify
         Height          =   285
         Left            =   2040
         MaxLength       =   10
         TabIndex        =   5
         Top             =   600
         Width           =   1455
      End
      Begin VB.TextBox txtnombre 
         Height          =   285
         Left            =   2040
         MaxLength       =   50
         TabIndex        =   3
         Top             =   240
         Width           =   4695
      End
      Begin VB.Label Label8 
         Alignment       =   1  'Right Justify
         Caption         =   "Monto:"
         Height          =   255
         Left            =   1320
         TabIndex        =   4
         Top             =   600
         Width           =   615
      End
      Begin MSForms.CommandButton CmdFiltrar 
         Height          =   375
         Left            =   10080
         TabIndex        =   6
         Top             =   600
         Width           =   1335
         Caption         =   " Filtrar"
         PicturePosition =   327683
         Size            =   "2355;661"
         Picture         =   "FPrecios.frx":058A
         Accelerator     =   70
         FontHeight      =   165
         FontCharSet     =   0
         FontPitchAndFamily=   2
         ParagraphAlign  =   3
      End
      Begin VB.Label Label7 
         Alignment       =   1  'Right Justify
         Caption         =   "Nombre:"
         Height          =   255
         Left            =   1320
         TabIndex        =   2
         Top             =   240
         Width           =   615
      End
   End
   Begin MSHierarchicalFlexGridLib.MSHFlexGrid HFG 
      Height          =   4575
      Left            =   120
      TabIndex        =   7
      Top             =   2280
      Width           =   11535
      _ExtentX        =   20346
      _ExtentY        =   8070
      _Version        =   393216
      FixedCols       =   0
      SelectionMode   =   1
      AllowUserResizing=   1
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      _NumberOfBands  =   1
      _Band(0).Cols   =   2
   End
   Begin VB.Label LabServicio 
      Alignment       =   2  'Center
      Appearance      =   0  'Flat
      BorderStyle     =   1  'Fixed Single
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   12
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H80000008&
      Height          =   375
      Left            =   120
      TabIndex        =   12
      Top             =   600
      Width           =   11535
   End
   Begin VB.Label labTitulo 
      Alignment       =   2  'Center
      AutoSize        =   -1  'True
      Caption         =   "SERVICIOS - PRECIOS"
      BeginProperty Font 
         Name            =   "Times New Roman"
         Size            =   18
         Charset         =   0
         Weight          =   700
         Underline       =   -1  'True
         Italic          =   -1  'True
         Strikethrough   =   0   'False
      EndProperty
      Height          =   420
      Left            =   120
      TabIndex        =   0
      Top             =   0
      Width           =   11535
   End
   Begin MSForms.CommandButton CmdNuevo 
      Height          =   375
      Left            =   120
      TabIndex        =   8
      Top             =   6960
      Width           =   2325
      Caption         =   "  Registrar nuevo precio"
      PicturePosition =   327683
      Size            =   "4101;661"
      Picture         =   "FPrecios.frx":0B24
      FontHeight      =   165
      FontCharSet     =   0
      FontPitchAndFamily=   2
      ParagraphAlign  =   3
   End
   Begin MSForms.CommandButton CmdModificar 
      Height          =   375
      Left            =   2640
      TabIndex        =   9
      Top             =   6960
      Width           =   1485
      Caption         =   "  Modificar"
      PicturePosition =   327683
      Size            =   "2619;661"
      Picture         =   "FPrecios.frx":0C7E
      FontHeight      =   165
      FontCharSet     =   0
      FontPitchAndFamily=   2
      ParagraphAlign  =   3
   End
   Begin MSForms.CommandButton CmdSalir 
      Height          =   375
      Left            =   10200
      TabIndex        =   11
      Top             =   6960
      Width           =   1485
      Caption         =   "  Salir"
      PicturePosition =   327683
      Size            =   "2619;661"
      Picture         =   "FPrecios.frx":1218
      FontHeight      =   165
      FontCharSet     =   0
      FontPitchAndFamily=   2
      ParagraphAlign  =   3
   End
   Begin MSForms.CommandButton CmdEliminar 
      Height          =   375
      Left            =   4320
      TabIndex        =   10
      Top             =   6960
      Width           =   1485
      Caption         =   "  Eliminar"
      PicturePosition =   327683
      Size            =   "2619;661"
      Picture         =   "FPrecios.frx":1372
      FontHeight      =   165
      FontCharSet     =   0
      FontPitchAndFamily=   2
      ParagraphAlign  =   3
   End
End
Attribute VB_Name = "FPrecios"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private servicioCod As String
Private dockCont As ClsDockControls

Private Sub buscar()
    Dim sql As New ClsSQL
    sql.setCampos Array(pre_id, pre_descripcion, _
                        caseFuncSQL(pre_tipo, Array("1", "2"), Array("'Monto'", "'Porcentaje'"), "Tipo"), _
                        mon_nombre, pre_monto)
    sql.setTablas Array(pre, mon)
    sql.setCondiciones Array(pre_mon_id & "=" & mon_id, _
                             pre_ser_id & "=" & servicioCod)
    If TxtNombre.Text <> "" Then
        sql.agregarCondicion pre_descripcion & " LIKE '" & TxtNombre.Text & "%'"
    End If
    If Val(txtMonto.Text) > 0 Then
        sql.agregarCondicion pre_monto & " = " & txtMonto.Text & ""
    End If
    sql.sSelect
    
    MUtiles.llenaGrillaSQL HFG, sql.cadena, _
                           Array(0, 350 * 15, 100 * 15, 80 * 15, 100 * 15), _
                           Array("Codigo", "Descripcion", "Tipo", "Moneda", "Monto"), _
                           Array(alineaDer, alineaIzq, alineaIzq, alineaIzq, alineaDer)
End Sub

Private Sub CmdFiltrar_Click()
    buscar
End Sub

Private Sub Form_Load()
    txtMonto.Text = Mascara("", False)
    'configurando los controles Dock
    Set dockCont = New ClsDockControls
    'seteamos el contenedor
    dockCont.setContainer Me.Height, Me.Width
    'seteamos los controles del contenedor
    dockCont.dock HFG, True, True, True, True
    dockCont.dock CmdNuevo, False, True, True, False
    dockCont.dock CmdModificar, False, True, True, False
    dockCont.dock CmdEliminar, False, True, True, False
    dockCont.dock CmdSalir, False, False, True, True
    dockCont.dock Me.labTitulo, True, True, False, True
    dockCont.dock Me.LabServicio, True, True, False, True
End Sub
Private Sub Form_Resize()
    dockCont.resize Me.Height, Me.Width
End Sub

Public Sub cargaServicio(codig As String)
    Me.LabServicio.Caption = ""
    
    servicioCod = codig
    
    Dim servicio As ClsServicio
    Set servicio = New ClsServicio
    servicio.consultaDatos codig
    LabServicio.Caption = servicio.nombre
    
    buscar
End Sub

Private Sub CmdNuevo_Click()
    FPreciosOpt.cargarServicio servicioCod
    mostrarForm FPreciosOpt
    buscar
End Sub

Private Sub CmdModificar_Click()
    Dim codigo As String
    codigo = HFG.TextMatrix(HFG.Row, 0)
    If Len(codigo) > 0 Then
        FPreciosOpt.cargarServicio servicioCod
        FPreciosOpt.cargaPrecio codigo
        mostrarForm FPreciosOpt, True
        buscar
    End If
End Sub

Private Sub CmdEliminar_Click()
    Dim codigo As String
    codigo = HFG.TextMatrix(HFG.Row, 0)
    If Len(codigo) > 0 Then
        If MsgBox(MConfirma_Borrar, vbExclamation + vbYesNo, "Confirmar") = vbYes Then
            Dim precio As ClsPrecio
            Set precio = New ClsPrecio
            precio.Borrar codigo
            buscar
        End If
    End If
    
End Sub

Private Sub txtMonto_KeyPress(KeyAscii As Integer)
    KeyAscii = NroDecimal(txtMonto, KeyAscii)
End Sub

Private Sub TxtMonto_LostFocus()
    txtMonto.Text = Strings.Trim$(txtMonto.Text)
    If Strings.LenB(txtMonto.Text) > 0 Then
        txtMonto.Text = Mascara(txtMonto.Text, False)
    End If
End Sub
Private Sub TxtNombre_LostFocus()
    TxtNombre.Text = Strings.Trim$(TxtNombre.Text)
End Sub
Private Sub CmdSalir_Click()
    Unload Me
End Sub
